package com.controller.content;

import com.dto.BusinessDto;
import com.pojo.Page;
import com.service.CommentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
@RequestMapping("/comments")
public class CommentsController {
	@Resource
	private CommentService commentService;

	@RequestMapping
	public String search(Model model, BusinessDto dto, @RequestParam(value = "pageIndex", required = false)Integer pageIndex) {
		Page page=new Page();
		page.setCurrentPage(pageIndex!=null ? pageIndex:1);
		model.addAttribute("list", commentService.getListByBusinessId(dto.getId(), page));
		dto.setPage(page);
		model.addAttribute("searchParam", dto);
		return "/content/commentList";
	}
}
